Dao = function(){
	this.dbm = new SocioMusicDBManager();
	this.addTag("all");
	this.TAGCLASS = 'tags';
	this.FILECLASS = 'files';
}

Dao.prototype.addTag = function(_tagName) {
	var tag = new Tag(_tagName);
	this.dbm.addObject(this.TAGCLASS,tag,
		function(){
			console.log(' tag "'+tag.name +'" added succesfully ');
		},
		function(){
			console.error('Could not add tag "'+tag.name +'" ');
		}
		);
};

Dao.prototype.getAllTags = function(_sucFunc) {
	var errFunc = function(){
		console.log('failed fetching all tags ');
	};
	
	this.dbm.getObjects(this.TAGCLASS, [], {},
		_sucFunc, function(){
		});
	
}

Dao.prototype.addFile = function(name, size, parentFolder, type, url, mainTagId) {
	var file = new File(name, size, parentFolder, type, url, mainTagId);
	this.dbm.addObject(this.FILECLASS,file,
		function(){
			console.log(' file "'+name +'" added succesfully ');
		},
		function(){
			//#TODO: use try catch and show appropriate error
			console.error('Could not add file "'+name +'" ');
		}
		);
};

Dao.prototype.updateFile = function(_id,_url) {
	this.dbm.updateObject(
		this.FILECLASS,
		{
			id   :  _id		
		},
		{
			url  : _url
		},
		function(){
		},
		function(){
			//#TODO: use try catch and show appropriate error
			console.error('Could not update file with id "'+ _id +'" with url : '+_url);
		}
		);	
};

Dao.prototype.getFileId = function(_size, _sucFunc){
	var errFunc = function(){
		console.log('checking if file with size: '+_size+'exists already');
	};
	this.dbm.getObjects(this.FILECLASS, ['id'], {size:_size},_sucFunc, function(){
	});
	
}

Dao.prototype.getFiles = function(_tagId, _sucFunc){
	if(parseInt(_tagId) === 1){
		return this.getAllFiles(_sucFunc);
	}
}

Dao.prototype.getAllFiles = function(_sucFunc){
	var errFunc = function(){
		console.log('failed fetching all files ');
	};

	this.dbm.getFiles(_sucFunc);

}